import Vue from 'vue'
import router from 'vue-router'
import Home from "@/views/Home";
import AllProject from "@/views/AllProject";
import Details from "@/views/Details";
import PDF_preview from "@/components/PDF_preview";
import Upload from "@/views/Upload";
import MyData from "@/views/MyData";
import MyApply from "@/components/MyApply";
import adminHome from "@/views/adminHome";
import ApplyDetail from "@/components/ApplyDetail";
import Login from "@/views/Login";
import CheckProjectList from "@/components/adminComponents/CheckProjectList";
import CheckInfo from "@/components/adminComponents/CheckInfo";
import Empty from "@/views/Empty";
import NeedDue from "@/components/NeedDue";
import HasCheckList from "@/components/HasCheckList";
import HasPayment from "@/components/HasPayment";
import RejectList from "@/components/RejectList";
import CheckedInfo from "@/components/adminComponents/CheckedInfo";
import AdminRejectApply from "@/components/adminComponents/AdminRejectApply";
import CheckedRejectInfo from "@/components/adminComponents/CheckedRejectInfo";
import ApplyRejectDetail from "@/components/ApplyRejectDetail";
import HasCheckApplyDetail from "@/components/HasCheckApplyDetail";
import AdminProject from "@/components/adminComponents/AdminProject";
import SignedOnline from "@/components/adminComponents/SignedOnline";
import SignedOnlineList from "@/components/adminComponents/SignedOnlineList";
import AddProject from "@/components/adminComponents/AddProject";
import AdminPayment from "@/components/adminComponents/AdminPayment";
import AdminRefund from "@/components/adminComponents/AdminRefund";
import AdminSigned from "@/components/adminComponents/AdminSigned";
import ProjectPayment from "@/components/adminComponents/ProjectPayment";
import HasSignedList from "@/components/adminComponents/HasSignedList";
import PDF_preview_Component from "@/components/adminComponents/PDF_preview_Component";
import NeedSigned from "@/components/NeedSigned";
import SignedNeedCheck from "@/components/adminComponents/SignedNeedCheck";
import HasSignedCheckList from "@/components/HasSignedCheckList";
import NeedToPayment from "@/components/NeedToPayment";
import MyMessage from "@/components/MyMessage";
import HasPaymentList from "@/components/adminComponents/HasPaymentList";
import RefundInfo from "@/components/adminComponents/RefundInfo";
import AdminFinishProject from "@/components/adminComponents/AdminFinishProject";
import FinishProject from "@/components/FinishProject";

Vue.use(router)

const originalReplace = router.prototype.replace
router.prototype.replace = function (location) {
    return originalReplace.call(this, location).catch(err => err)
}

export default new router({
    routes: [

        {
            path: '/adminLogin',
            component: Login,
            name: 'login',
            meta: {
                requireAuth: false
            }
        },
        {
            path: '/empty',
            component: Empty,
            meta: {
                requireAuth: false
            }
        },
        {
            path: '*',
            component: Home,
            name: 'Home',
            meta: {
                requireAuth: false
            }
        },
        {
            path: '/allProject',
            component: AllProject,
            name: 'AllProject',
            meta: {
                requireAuth: false
            }
        },
        {
            path: '/details',
            component: Details,
            name: 'details',
            meta: {
                requireAuth: false
            }
        },
        {
            path: '/upload',
            component: Upload,
            name: 'upload',
            meta: {
                requireAuth: true,
                roles: ["student"]
            },
        },
        {
            path: '/pdf_upload',
            component: PDF_preview,
            meta: {
                requireAuth: true,
                roles: ["student"]
            }
        },
        {
            path: '/adminHome',
            component: adminHome,
            redirect: '/checkProject',
            meta: {
                requireAuth: true,
                roles: ["school", "bureau"]
            },
            children: [
                {
                    path: '/checkProject',
                    component: CheckProjectList,
                    meta: {
                        requireAuth: true,
                        roles: ["school", "bureau"]
                    }
                },
                {
                    path: '/pdf',
                    component: PDF_preview,
                    name: 'pdf',
                    meta: {
                        requireAuth: true,
                        roles: ["school", "bureau"]
                    }
                },
                {
                    path: '/checkInfo',
                    component: CheckInfo,
                    meta: {
                        requireAuth: true,
                        roles: ["school", "bureau"]
                    }
                },
                {
                    path: '/adminRefund',
                    component: AdminRefund,
                    meta: {
                        requireAuth: true,
                        roles: ["school", "bureau"]
                    }
                },
                {
                    path: '/refundInfo',
                    component: RefundInfo,
                    meta: {
                        requireAuth: true,
                        roles: ["school", "bureau"]
                    }
                },
                {
                    path: '/adminSigned',
                    component: AdminSigned,
                    meta: {
                        requireAuth: true,
                        roles: ["school", "bureau"]
                    }
                },
                {
                    path: '/checkedInfo',
                    component: CheckedInfo,
                    meta: {
                        requireAuth: true,
                        roles: ["school", "bureau"]
                    }
                },
                {
                    path: '/adminRejectApply',
                    component: AdminRejectApply,
                    meta: {
                        requireAuth: true,
                        roles: ["school", "bureau"]
                    }
                },
                {
                    path: '/checkedRejectInfo',
                    component: CheckedRejectInfo,
                    meta: {
                        requireAuth: true,
                        roles: ["school", "bureau"]
                    }
                },
                {
                    path: '/adminProject',
                    component: AdminProject,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                },
                {
                    path: '/signedOnline',
                    component: SignedOnline,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                },
                {
                    path: '/hasSignedList',
                    component: HasSignedList,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                },
                {
                    path: '/signedOnlineList',
                    component: SignedOnlineList,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                },
                {
                    path: '/addProject',
                    component: AddProject,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                },
                {
                    path: '/signedNeedCheck',
                    component: SignedNeedCheck,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                },
                {
                    path: '/adminFinishList',
                    component: AdminFinishProject,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                },
                {
                    path: '/adminPayment',
                    component: AdminPayment,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                },
                {
                    path: '/projectPayment',
                    component: ProjectPayment,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                },
                {
                    path: '/pdf_preview_Component',
                    component: PDF_preview_Component,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                },
                {
                    path: '/hasPaymentList',
                    component: HasPaymentList,
                    meta: {
                        requireAuth: true,
                        roles: ["school","bureau"]
                    }
                }
            ]
        },
        {
            path: '/myData',
            component: MyData,
            // 只要我们访问了home这个地址，我们就让他重定向到welcome这个地址  这个地方写斜线行，不写也行
            redirect: '/myApply',
            meta: {
                requireAuth: true,
                roles: ["student"]
            },
            // 二级路由
            children: [
                {
                    path: '/myApply',
                    component: MyApply,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/needDue',
                    component: NeedDue,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/applyDetails',
                    component: ApplyDetail,
                    name: 'applyDetails',
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/hasCheckList',
                    component: HasCheckList,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/hasPayment',
                    component: HasPayment,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/rejectList',
                    component: RejectList,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/applyRejectDetail',
                    component: ApplyRejectDetail,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/refundInfoS',
                    component: RefundInfo,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/hasCheckApplyDetail',
                    component: HasCheckApplyDetail,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/needSigned',
                    component: NeedSigned,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/refundInfo',
                    component: RefundInfo,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/toSigned',
                    component: SignedOnline,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/hasSignedCheckList',
                    component: HasSignedCheckList,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/needToPayment',
                    component: NeedToPayment,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/myMessage',
                    component: MyMessage,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                },
                {
                    path: '/finishProject',
                    component: FinishProject,
                    meta: {
                        requireAuth: true,
                        roles: ["student"]
                    }
                }
            ],
        },
    ],
})






